package com.jt.controller;

import com.jt.pojo.User;
import com.jt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
public class UserController {
    @Autowired
    private UserService userService;
@RequestMapping("/findAll")
    public List<User> findAll(){
    return userService.findAll();
}
@DeleteMapping("/user/{id}")
    public String deleteUserById(User user){
     userService.deleteUserById(user);
     return "删除成功";
}
@PostMapping("/saveUser")
    public String addUser(@RequestBody User user){
    System.out.println(user);
    userService.addUser(user);
    return "增加数据成功";
}
@PutMapping("/updateUser")
    public String updateUser(@RequestBody User user){
    userService.updateUser(user);
    return "修改成功";
}

}
